import { IQueue } from "./IQueue";
export class ArrayQueue<T> implements IQueue<T> {
  private data: T[] = [];
  constructor(data?: T[]) {
    this.data = data || [];
  }
  enQueue(item: T) {
    this.data.push(item);
  }
  deQueue() {
    if (!this.isEmpty()) {
      return this.data.shift();
    }
  }
  toString() {
    return String(this.data);
  }
  size() {
    return this.data.length;
  }
  isEmpty() {
    return this.data.length === 0;
  }
  peek() {
    return this.data[this.data.length - 1];
  }
  clear() {
    this.data = [];
  }
}

const queue1 = new ArrayQueue<number>();

queue1.enQueue(1);
queue1.enQueue(2);
queue1.enQueue(3);
console.log(queue1.toString());
queue1.deQueue();
console.log(queue1.toString());

export {};
